package cn.sell.bpmn.listener;

import lombok.extern.log4j.Log4j2;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;

@Log4j2
public class StartListener implements ExecutionListener {
    /**
     *
     */
    private static final long serialVersionUID = -4768395048131200982L;

    @Override
    public void notify(DelegateExecution execution) {
        // TODO:
        log.info("=================================::开始节点：StartListener");
//        bizlog.info("获取变量");
        System.out.println("=================================::"
                + execution.getCurrentActivityId());

//        Map<String, Object> param = ActivitiUtil.getRuntimeService()
//                .getVariables(execution.getId());
//        param.put("applst", E_APPLST.LR);
//        Map<String, Object> result = new HashMap<String, Object>();
//        result = LnUtil.flowCheckInteface(param);
//        boolean flag = (boolean) result.get("flag");
//        String erortx = (String) result.get("erortx");
        //判断校验是否合规，如果不合规则反馈错误
//        if (!flag) {
//            throw BpmErr.Bpm.E0015(erortx);
//        }

//        IoLnSvcTypeImpl ser = new IoLnSvcTypeImpl();
//        cn.sunline.ltts.busi.iobus.servicetype.ln.LnSvcType.FlowProcessSer.Output outputDeal = SysUtil
//                .getInstance(cn.sunline.ltts.busi.iobus.servicetype.ln.LnSvcType.FlowProcessSer.Output.class);
//        try {
//            ser.flowProcessSer(param, outputDeal);
//        } catch (Exception e) {
//            e.printStackTrace();
//            throw BpmErr.Bpm.E0021();
//        }
//        //参数设置
//
////           ActivitiUtil.getRuntimeService().setVariables(execution.getId(), param);
//        ActivitiUtil.getRuntimeService().setVariablesLocal(execution.getId(), param);
//        bizlog.info("登记流程实例信息");
//        BpmComUtil.regBpmWfinstForStartProcess(param, BpmWfprodDao.selectOne_odb1(
//                param.get("wfprcd").toString(), true),
//                execution.getProcessInstanceId());
//        bizlog.info("起始节点登记流程执行item信息");
//        BpmWfinst inst = BpmWfinstDao.selectOne_odb1(
//                execution.getProcessInstanceId(), false);
//        if (inst == null) {
//            throw BpmErr.Bpm.E0013();
//        }
//
//        BpmComUtil.registerItem(inst, "Start Process", "流程启动", execution);


    }

}
